﻿using chudb;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");

            using(var db = ChuDB.Open("test.db"))
            {
                var sp = db.TakeSpace("col1");
                sp.EnsureIndex("IX_name", "$.name");
                sp.Goto("123");
                sp.Store("name", "wang");
                sp.Store("xxx3", 3344);
                sp.Remove("xxx");
                sp.DeleteNow();
                sp.Goto("321");
                sp.Store("name", "kit");
                sp.Store("xxx3", 3344);
                sp.Goto("322");
                sp.Store("name", "kit");
                sp.Store("xxx3", 3345);
                var a = sp.Find("321");
                var x = sp.Count;
                ;
                sp.Goto("123");
                var b = sp.NewQuery().Where(Query.EQ("name", "kit")).OrderBy("xxx3", Query.Descending);
                Console.WriteLine(b.Count);
                Console.WriteLine(b.First()["xxx3"].AsDecimal);
                Console.WriteLine(b.First().Id.AsString);
            }
        }
    }
}
